﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CNShapes;
using System.Drawing;

namespace CNPageViewer
{
    /// <summary>
    /// Shows the pointer shape. This is just shown as two concentric circles.
    /// </summary>
    public class ShapeRenderer_Pointer : IShapeRenderer
    {
        #region IShapeRenderer methods

        /// <summary>
        /// We render the pointer as concentric colored circles.
        /// </summary>
        public void renderShape(Shape shape, Graphics graphics, PageViewerControl pageViewerControl)
        {
            Shape_Pointer shapePointer = (Shape_Pointer)shape;
            PointF clientPosition = pageViewerControl.shapePointToClientPoint(shapePointer.getPointerPosition());

            // We draw a red circle...
            float fPenWidth = 2f * pageViewerControl.ZoomFactor;
            float fRadius = 5f * pageViewerControl.ZoomFactor;
            float fDiameter = fRadius * 2f;
            Pen pen = new Pen(Color.Red, fPenWidth);
            RectangleF rect = new RectangleF(clientPosition.X - fRadius, clientPosition.Y - fRadius, fDiameter, fDiameter);
            graphics.DrawEllipse(pen, rect);
            
            // We draw a yellow circle...
            fRadius = 2f * pageViewerControl.ZoomFactor;
            fDiameter = fRadius * 2f;
            pen = new Pen(Color.Yellow, fPenWidth);
            rect = new RectangleF(clientPosition.X - fRadius, clientPosition.Y - fRadius, fDiameter, fDiameter);
            graphics.DrawEllipse(pen, rect);
        }

        /// <summary>
        /// Returns the type of the shape we're managing.
        /// </summary>
        public Type getShapeType()
        {
            return typeof(Shape_Pointer);
        }

        #endregion
    }
}
